import request from 'lib/request';

// 获取家庭成员列表
export function getFamilyList (patientId, hospitalId) {
  let body = {
    patientId,
    hospitalId,
  }
  return request("wechat/patient/family/list?"+"patientId="+patientId+"&hospitalId="+hospitalId,{
    method: 'GET',
  })
}


//家庭成员详情
export function getFamilyMember(id) {
  let body = {
     id,
  }
  return request("wechat/patient/family/detail?"+"id="+id,{
    method: "GET",
  })
}


// 添加家庭成员
// data: { name, gender, birthday, relation, idnumber }
export function addFamilyMember(data) {
  const body = new FormData();
  Object.keys(data).forEach(key => body.append(key, data[key]));
  return request.post('wechat/patient/family/add', { body });
}

// 删除家庭成员
export function deleteFamilyMember(id) {
  const body = new FormData();
  body.append('id', id);
  return request.post('wechat/patient/family/delete', { body });
}

// // 修改家庭成员详情
// data: { name, gender, birthday, relation, idnumber }
export function updateFamilyMember(data) {
  const body = new FormData();
  Object.keys(data).forEach(key => body.append(key, data[key]));
  return request.post('wechat/patient/family/update', { body });
}
